<template>
    <view>
        <emptyList v-if="data.list.length == 0" :empty_list_title="!is_search?'暂时没有相关的全国邮寄商品':(search_value?'搜不到，换个关键字试试吧':'搜一搜商品名、商品介绍')"></emptyList>
        <view class="flex flex-wrap padding-6">
            <view v-for="(info, key) in data.list" :key="key" 
                @tap="$store.commit('userNavTo', '/seller/item/list?seller_id='+info.seller_user_id+'&buy_mode=2&item_id='+info.item_id)">
                <view class="bg-white margin-6 radius-16 padding-6">
                    <view>
                        <image mode="aspectFill" class="radius-10" style="width: 222rpx; height:200rpx;" :src="info.logo | ossUrl(222)"></image>
                    </view>
                    <view class="text-cut-1 text-13 margin-top-6 text-bold" style="width: 222rpx;">
                        {{info.item_name}}
                    </view>
                    <view v-if="info.content" class="text-cut-2 text-11 text-gray" style="width: 222rpx;">
                        {{info.content}}
                    </view>
                    <view class="text-cut-1 text-11 text-nddyny" style="width: 222rpx;">
                        赠送金券 {{info.bonus_gold_coupon_ratio}}%
                    </view>
                    <view class="text-cut-1 text-red" style="width: 222rpx;">
                        <text class="text-xs">￥</text>
                        <text class="text-df">{{info.price | floor}}</text>
                        <text v-if="info.oprice > 0" class="text-xs text-through text-gray margin-left-6">
                            <text>￥</text>
                            <text>{{info.oprice | floor}}</text>
                        </text>
                    </view>
                </view>
            </view>
        </view>
        <footRight v-if="!is_search" class="margin-bottom-100" :tapRefresh="()=>{getList($api.list_action_force_init)}"></footRight>
    </view>
</template>

<script>
    import footRight from '@/components/nddyny/common/footRight.vue';
    export default {
        components: {
            footRight,
        },
        props: ['data_append', 'is_search'],
        data() {
            let data = {
                offset: 0,
                limit: 21,
                stop: false,
                list: [],
            };
            return {
                search_value: null,
                data_bak: this.$nddyny.object.copy(data),
                data: this.$nddyny.object.copy(data),
            }
        },
        methods: {
            initData() {
                this.search_value = null;
                this.$set(this, 'data', this.$nddyny.object.copy(this.data_bak));
            },
            refreshList() {
                this.getList(this.$api.list_action_force_init);
            },
            getList(action, search_value) {
                this.search_value = search_value;
                let data_append = this.$nddyny.object.copy(this.data_append.form);
                if (search_value) {
                    data_append['search_value'] = search_value;
                }
                this.$api.list(this, {
                    action,
                    data_append,
                    url: '/seller/item/list',
                    success: (Result, data_key) => {
                        if (this.$api.form.toast(this, Result, data_key)) return;
                        this.$set(this.data, 'list', this.data.list.concat(Result.result.list));
                    }
                });
            }
        }
    }
</script>
